import sys
import math
from collections import defaultdict
T = int(input())
for _ in range(T):
n = int(input())
k=1
while n%2==0:
n=n//2
k*=2
if n==1:
print('-1')
else:
print(min(n,2*k))
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
const ll mod = 1e9+7;
const ll INF = 2e18;
void solve() {
ll n; cin >> n;
ll po2=1;
while(n%2==0){
n/=2;
po2*=2;
}
if(n==1) cout << -1 << endl;
else if(n>=(2*po2+1)) cout << po2*2 << endl;
else cout << n << endl;
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
ll t; cin >> t;
for(ll i = 0; i < t; i++) solve();
return 0;
}
45A - Codecraft III | 1242A - Tile Painting |
1663E - Are You Safe | 1663D - Is it rated - 3 |
1311A - Add Odd or Subtract Even | 977F - Consecutive Subsequence |
939A - Love Triangle | 755A - PolandBall and Hypothesis |
760B - Frodo and pillows | 1006A - Adjacent Replacements |
1195C - Basketball Exercise | 1206A - Choose Two Numbers |
1438B - Valerii Against Everyone | 822A - I'm bored with life |
9A - Die Roll | 1430B - Barrels |
279B - Books | 1374B - Multiply by 2 divide by 6 |
1093B - Letters Rearranging | 1213C - Book Reading |
1468C - Berpizza | 1546B - AquaMoon and Stolen String |
1353C - Board Moves | 902A - Visiting a Friend |
299B - Ksusha the Squirrel | 1647D - Madoka and the Best School in Russia |
1208A - XORinacci | 1539B - Love Song |
22B - Bargaining Table | 1490B - Balanced Remainders |